﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using LLFM.CAT.Model;
using LLFM.CAT.Service;
using System.IO;

public partial class Admin_Product_ModifyProduct : AdminPage
{
    public string strImagePath;
    public int seriesId;
    public string name;
    public string model;
    public string bucketCapacity;
    public string workWeight;
    public string engine;
    public string power;
    public string applyTo;
    public string shortDescription;
    public string advantage;
    public string pdfUrl;
    public string flashUrl;
    public string description;
    public int productId;
    public List<M_SeriesImages> imags = new List<M_SeriesImages>();
    public List<M_Series> serviesList = new List<M_Series>();
    protected void Page_Load(object sender, EventArgs e)
    {
        productId = RequestHelper.GetInt("productId",0);
        bool objNotNull = false;
        if(productId > 0 )
        {
            M_Products product = ProductsService.GetProductById(productId);
            serviesList = SeriesService.GetSeriesList(1);
            if(product != null)
            {
                objNotNull = true;
                seriesId = product.SeriesId;
                name = product.Name;
                model = product.Model;
                bucketCapacity = product.BucketCapacity;
                workWeight = product.WorkWeight;
                engine = product.Engine;
                power = product.Power;
                applyTo = product.ApplyTo;
                shortDescription = product.ShortDescription;
                advantage = product.Advantage;
                pdfUrl = product.UserManual;
                M_ProductExtention proEx = ProductExtentionService.GetProductExtentionByProductId(product.Id);
                if(proEx != null)
                {
                    flashUrl = proEx.FlashUrl;
                    description = proEx.Description.Replace("\n", "").Replace("\r\n", "");
                }
                imags.Add(new M_SeriesImages() { 
                    ImageUrl = product.SeriesListImageBig,
                    Name = Path.GetFileName(product.SeriesListImageBig)
                });
                imags.Add(new M_SeriesImages()
                {
                    ImageUrl = product.SeriesDetailImageBig,
                    Name = Path.GetFileName(product.SeriesDetailImageBig)
                });
                imags.Add(new M_SeriesImages()
                {
                    ImageUrl = product.SeriesDetailImageList,
                    Name = Path.GetFileName(product.SeriesDetailImageList)
                });
                imags.Add(new M_SeriesImages()
                {
                    ImageUrl = product.UserManualImage,
                    Name = Path.GetFileName(product.UserManualImage)
                });
            }
        }
        if (!objNotNull)
        {
            Response.Redirect("ProductList.aspx");
        }
        
    }
}